package com.itestor.iptv.modules.common.actions;


import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import com.itestor.iptv.global.actions.AbstractPagedQueryAction;
import com.itestor.iptv.global.bean.AbstractPagedQuery;
import com.itestor.iptv.modules.common.bean.RobotRealtimeQuery;
import com.itestor.iptv.modules.common.vo.RobotRealtimeBaan;
import com.itestor.iptv.modules.ne.service.RobotManageService;

/**
 * 
 * @author Mr.li
 * 
 */
public class RobotRealtimeQueryAction extends AbstractPagedQueryAction {

    /**
     * Logger for this class.
     */
    private static final Logger logger = Logger
            .getLogger(RobotRealtimeQueryAction.class);

    private RobotManageService robotManageService;
    
    /**
     * 获取选择设备列表.
     * @param form 
     * @param request 
     * @param pagerCount 
     * @param pagerOffset 
     * @return AbstractPagedQuery
     * @throws Exception  
     */   
    @SuppressWarnings("unchecked")
    public AbstractPagedQuery doPagedQuery(ActionForm form,
            HttpServletRequest request, int pagerCount, int pagerOffset)
            throws Exception {
        RobotRealtimeQuery robotRealtimeQuery = new RobotRealtimeQuery();   
        try{
            String queryRobotName = request.getParameter("queryRobotName");
            robotRealtimeQuery.setPagerCount(pagerCount);
            robotRealtimeQuery.setPagerOffset(pagerOffset);

            if (!StringUtils.isEmpty(queryRobotName)) {
                robotRealtimeQuery.setRobotName(queryRobotName);
                request.setAttribute("queryRobotName", queryRobotName);
            }

            robotManageService.queryRealtimeDataList(robotRealtimeQuery);
            List<RobotRealtimeBaan> list = (List<RobotRealtimeBaan>) robotRealtimeQuery
                    .getQueryResults();

            for (RobotRealtimeBaan raaltimeBean : list) {
                robotManageService.getRealtimeQuality(raaltimeBean);
                robotManageService.getRealtimeLostRate(raaltimeBean);
                robotManageService.getRealtimeQosRecord(raaltimeBean);                
            }
        
        }catch(Exception e){
            e.printStackTrace();
        }
        
        return robotRealtimeQuery;
    }
    
    /**
     * 　
     * @param pRobotManageService
     */
    public void setRobotManageService(RobotManageService pRobotManageService) {
        robotManageService = pRobotManageService;
    }
    
    

}